#include <stdlib.h>
#include <string.h>

#include <global/malloc.h>

void * s_malloc(size_t s)
{
	register void * p = malloc(s);
	if (p != NULL)
	{
		bzero(p, s);
	}
	return p;
}

void * t_malloc(size_t s)
{
	register void * p = malloc(s);
	if (p == NULL)
	{
		exit(-1);
	}
	bzero(p, s);
	return p;
}

void * o_malloc(t_fd f, size_t s)
{
	static const char m[28] = "minbasiclib: bad allocate.\n";
	register void * p = malloc(s);
	if (p == NULL)
	{
		write(f, m, 28);
	}
	bzero(p, s);
	return p;
}
